package com.week10.mybatis_annotation;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

@Component
public class BeanUnits implements ApplicationContextAware {

    private static ApplicationContext appCxt;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        if (appCxt == null) {
            appCxt = applicationContext;
        }
    }

    public static Object getBean(String beanName){
        return appCxt.getBean(beanName);
    }
}
